package com.example.a14110100409.yuejiandemo.model;

import com.example.a14110100409.yuejiandemo.javabean.OrderInfo;
import com.example.a14110100409.yuejiandemo.javabean.User;
import com.example.a14110100409.yuejiandemo.javabean.UserCollect;
import com.example.a14110100409.yuejiandemo.javabean.UserInfo;
import com.example.a14110100409.yuejiandemo.javabean.UserOrder;
import com.example.a14110100409.yuejiandemo.javabean.UserShaitu;
import com.example.a14110100409.yuejiandemo.service.ActImpls;
import com.example.a14110100409.yuejiandemo.service.UserService;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;

import org.json.JSONObject;

import java.util.List;

import okhttp3.MultipartBody;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by owner on 2017/9/25.
 */

public class UserModel {
    private Retrofit retrofit;
    public UserModel(){
        retrofit = new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl("http://172.24.10.175/workout/api.php/")
                .build();
    }
    public retrofit2.Call<User> login(String tel, String pwd){
        UserService userService = retrofit.create(UserService.class);
        return userService.getLogin(tel,pwd);
    }

    public retrofit2.Call<User> register(String tel,String password){
        UserService userService = retrofit.create(UserService.class);
        return userService.register(tel,password);
    }
    public retrofit2.Call<User> getUserinfo(int userid){
        UserService userService = retrofit.create(UserService.class);
        return userService.getuserinfo("lgj98rfkiqvenhrk2o7oe2po81",userid);
    }
    public retrofit2.Call<UserInfo> updateName(int userid, String username){
        UserService userService = retrofit.create(UserService.class);
        return userService.updatename("lgj98rfkiqvenhrk2o7oe2po81",userid,username);
    }
    public retrofit2.Call<Integer> updatePwd(int userid, String password){
        UserService userService = retrofit.create(UserService.class);
        return userService.updatepwd("lgj98rfkiqvenhrk2o7oe2po81",userid,password);
    }
    public retrofit2.Call<List<UserShaitu>> getusershaitu(int userid){
        UserService userService = retrofit.create(UserService.class);
        return userService.getusershaitu("shaitu","lgj98rfkiqvenhrk2o7oe2po81",userid);
    }
    public retrofit2.Call<List<UserCollect>> getcollect(int userid){
        UserService userService = retrofit.create(UserService.class);
        return userService.getcollect("fans","lgj98rfkiqvenhrk2o7oe2po81",userid);
    }
    public retrofit2.Call<List<UserOrder>> getallorder(int userid){
        UserService userService = retrofit.create(UserService.class);
        return userService.getallorder("sign",userid,"lgj98rfkiqvenhrk2o7oe2po81");
    }
    public retrofit2.Call<List<UserOrder>> getfinorder(int vstate,int userid){
        UserService userService = retrofit.create(UserService.class);
        return userService.getordertype("sign",userid,vstate,"lgj98rfkiqvenhrk2o7oe2po81");
    }
    public retrofit2.Call<Integer> getClubState(String fan_id,int userid){
        UserService userService = retrofit.create(UserService.class);
        return  userService.getClubState(fan_id,userid,"1","lgj98rfkiqvenhrk2o7oe2po81");
    }
    public retrofit2.Call<Integer> changeClubState(int userid,String fan_id){
        UserService userService = retrofit.create(UserService.class);
        return  userService.changeClubState("lgj98rfkiqvenhrk2o7oe2po81",userid,fan_id,"1");
    }
    public retrofit2.Call<Integer> getTeaState(String fan_id,int userid){
        UserService userService = retrofit.create(UserService.class);
        return  userService.getTeaState(fan_id,userid,"2","lgj98rfkiqvenhrk2o7oe2po81");
    }
    public retrofit2.Call<Integer> changeTeaState(int userid,String fan_id){
        UserService userService = retrofit.create(UserService.class);
        return  userService.changeClubState("lgj98rfkiqvenhrk2o7oe2po81",userid,fan_id,"2");
    }

    public retrofit2.Call<OrderInfo> getOrderInfo(String id, String type){
        UserService userService = retrofit.create(UserService.class);
        return  userService.getOrder(id,type,"lgj98rfkiqvenhrk2o7oe2po81");
    }

    //发布晒图
    public Call<okhttp3.ResponseBody> signPic(int userid, String title, MultipartBody.Part file){
        ActImpls actImpls = retrofit.create(ActImpls.class);
        return  actImpls.signpic(userid,title,file);
    }

}
